package com.cskaoyan.service;

import com.cskaoyan.bean.Address;
import com.cskaoyan.bean.AddressExample;
import com.cskaoyan.bean.ListData;
import com.cskaoyan.bean.vo.DeliveryAddress;
import com.cskaoyan.mapper.AddressMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 杨杰
 * @version V1.0
 * @Package com.cskaoyan.service
 * @date 2020/12/5 17:27
 * @Copyright © 暂时还没有
 */
@Service
public class AddressServiceImp implements AddressService{
    @Autowired
    AddressMapper addressMapper;
    @Override
    public ListData<DeliveryAddress> queryAddressList
            (Integer page, Integer limit, String sort, String order,Integer userId,String name) {

        List<DeliveryAddress> deliveryAddress = addressMapper.queryDetailAddress(userId, name,page-1,limit);
        //封装
        ListData<DeliveryAddress> listData = new ListData<>();
        listData.setItems(deliveryAddress);
        PageInfo<DeliveryAddress> pageInfo = new PageInfo<>(deliveryAddress);
        long total = pageInfo.getTotal();
        listData.setTotal((int) total);

        return listData;
    }
}
